import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator

mpl.rcParams["axes.unicode_minus"] = False

X = [5, 10, 100, 1000, 10000, 100000]
Y1 = [1.0, 0.5, 0.15, 0.094, 0.1041, 0.09935]
Y2 = [1.0, 0.5, 0.1, 0.051, 0.054, 0.04905]
Y3 = [0.0, 0.3, 0.1, 0.094, 0.1041, 0.09935]
Y4 = [0.0, 0.2, 0.09, 0.05, 0.054, 0.04905]

plt.plot(X, Y1, ls='--', color='g', linewidth=2, marker='D', markersize=8)
plt.plot(X, Y2, ls='--', color='coral', linewidth=2, marker='v', markersize=8)
plt.plot(X, Y3, ls='--', color='teal', linewidth=2, marker='X', markersize=8)
plt.plot(X, Y4, ls='--', color='navy', linewidth=2, marker='^', markersize=8)
# plt.title('Squares',fontsize=24)
plt.tick_params(axis='both', which='major', labelsize=14)
plt.ylabel(r'Sampling probability', fontsize=14)
plt.xlabel('Flow size (pkt num.)', fontsize=14)
x_major_locator = MultipleLocator(1)
ax = plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
plt.xscale('log')
plt.xlim(3, 10 ** 5 + 100000)
plt.ylim(-0.02, 1.02)
plt.legend(
    ['Adaptive $(P_{min}=10\%)$', 'Adaptive $(P_{min}=5\%)$', 'Constant $(10\%)$', 'Constant $(5\%)$'],
    frameon=False, fontsize=14)
plt.axhline(y=10 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=20 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=30 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=40 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=50 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=60 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=70 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=80 / 100, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=90 / 100, color='lightgray', ls=':', linewidth=1)
plt.savefig('sample.pdf', bbox_inches='tight')
plt.show()
